﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MobileShop.Controls;
using POSSystem.BLL;

namespace MobileShop
{
    public partial class Wishlist :BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SessionUser == null || SessionUser.RowCount == 0)
                this.Response.Redirect("Login.aspx?url=Wishlist.aspx");

            if (!IsPostBack)
            {
                lstProduct.Rebind();
                PageMap = string.Format("Wishlist[{0}]", this.ResolveUrl("~/Wishlist.aspx"));
            }
        }

        protected void dataPager_OnPageIndexChanged(object sender, PageIndexChangedEventArgs e)
        {
            lstProduct.Rebind();
        }

        protected void lstProduct_OnNeedDataSource(object sender, EventArgs e)
        {
            View_WishList prods = new View_WishList();
            int count = prods.Search(View_WishList.ColumnNames.CustomerID + "=" + View_Customers.GetCurrentUser().s_ID, View_WishList.ColumnNames.ProductName + " desc", dataPager.CurrentPageIndex * dataPager.PageSize, dataPager.PageSize);
            lstProduct.DataSource = prods.DefaultView;
            dataPager.TotalItems = count;
        }
    }
}